//
//  entity.cpp
//  template4
//
//  Created by Xiaochen Lian on 5/15/12.
//  Copyright (c) 2012 University of California, Los Angeles. All rights reserved.
//

#include "entity.h"

IEntity::IEntity() {
    m_visible = true;
    m_model_pos = 0.0;
    m_mass_center = 0.0;
    m_mass_center.w = 1.0;
    m_children.clear();
    parent = NULL;
}

IEntity::~IEntity() {
    for (int i = 0; i < m_children.size(); ++i)
        delete m_children[i];
    m_children.clear();
}

inline void IEntity::set_type(PART_TYPE type) { m_type = type; }

inline PART_TYPE IEntity::get_type() { return m_type; }

inline void IEntity::set_pos(const point4 &pos) { m_model_pos = pos; }

inline point4 IEntity::get_pos() { return m_model_pos; }

point4 IEntity::get_mass_center()
{
    return m_mass_center;
}

inline bool IEntity::is_right() { return false; }

void IEntity::add_child(IEntity *part)
{
    part->parent = this;
    m_children.push_back(part);
    part->build_model(m_mass_center);
}

void IEntity::draw_axis(const mat4 &tfm_parent) {}

mat4 IEntity::tfm_from_status(const bird_status &nstatus)
{
    return mat4(1.0);
}

vec4 IEntity::aerodynamics(const bird_status &nstatus, const mat4 &tfm, const double timestep)
{ 
    return vec4(0.0); 
}

void IEntity::update(const bird_status &cstatus, const mat4 tfm_parent) {}